package com.ihm;
import javax.swing.*;

import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
public class FenetreAjouterParcour extends JDialog {
	private JLabel labeltitre ;
	private JLabel labeldescription ;
	private JLabel labelidcarte ;
	private static JTextField texttitre ;
	private static JTextArea textdescription ;
	private static JTextField textidcarte ;
	private JButton buttonajouter ;
	private JButton buttoneffacer ;
	private JButton buttonannuler ;
	private JPanel panelid ;
	private JPanel paneltitre ;
	private JPanel paneldescription ;
	private JPanel panelbutton ;
	private JPanel mainpanel ;
	public static JTextField getTexttitre() {
		return texttitre;
	}
	public static void setTexttitre(JTextField texttitre) {
		FenetreAjouterParcour.texttitre = texttitre;
	}
	public static JTextArea getTextdescription() {
		return textdescription;
	}
	public static void setTextdescription(JTextArea textdescription) {
		FenetreAjouterParcour.textdescription = textdescription;
	}
	public static JTextField getTextidcarte() {
		return textidcarte;
	}
	public static void setTextidcarte(JTextField textidcarte) {
		FenetreAjouterParcour.textidcarte = textidcarte;
	}
    public FenetreAjouterParcour()
	{
		this.setTitle("Ajouter un nouveau parcour");
		this.setSize(600,400);
		this.setResizable(false);
		this.setLocationRelativeTo(null);
		this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
		this.setModal(true);
		createcomponent();
		createpanel();
		addcomponent();
		this.add(mainpanel);
		event();
		this.setVisible(true);
	}
	public void createcomponent()
	{
		labeltitre = new JLabel("Titre : ");
		labeltitre.setFont(new Font("italique",Font.BOLD,20));
		labeldescription = new JLabel("Description : ");
		labeldescription.setFont(new Font("italique",Font.BOLD,20));
		labelidcarte = new JLabel("ID_Carte : ");
		labelidcarte.setFont(new Font("italique",Font.BOLD,20));
		texttitre = new JTextField();
		texttitre.setMaximumSize(new Dimension(150,20));
		texttitre.setSize(150,20);
		textdescription = new JTextArea();
		textdescription.setMaximumSize(new Dimension(200,100));
		textdescription.setSize(200,100);
		textidcarte = new JTextField();
		textidcarte.setMaximumSize(new Dimension(150,20));
		textidcarte.setSize(150,20);
		buttonajouter = new JButton("Ajouter");
		buttonajouter.setMaximumSize(new Dimension(80,20));
		buttonajouter.setSize(80,20);
		buttoneffacer = new JButton("Effacer");
		buttoneffacer.setMaximumSize(new Dimension(80,20));
		buttoneffacer.setSize(80, 20);
		buttonannuler = new JButton("Annuler");
		buttonannuler.setMaximumSize(new Dimension(80,20));
		buttonannuler.setSize(80, 20);
	}
	public void createpanel()
	{
		panelid = new JPanel();
		panelid.setLayout(new BoxLayout(panelid,BoxLayout.X_AXIS));
		paneltitre = new JPanel();
		paneltitre.setLayout(new BoxLayout(paneltitre,BoxLayout.X_AXIS));
		paneldescription =new JPanel();
		paneldescription.setLayout(new BoxLayout(paneldescription,BoxLayout.X_AXIS));
		panelbutton = new JPanel();
		panelbutton.setLayout(new BoxLayout(panelbutton,BoxLayout.X_AXIS));
		mainpanel = new JPanel();
		mainpanel.setLayout(new BoxLayout(mainpanel,BoxLayout.Y_AXIS));
	}
	public void addcomponent()
	{
		paneltitre.add(labeltitre);
		paneltitre.add(Box.createHorizontalStrut(50));
		paneltitre.add(texttitre);
		paneldescription.add(labeldescription);
		paneldescription.add(Box.createHorizontalStrut(50));
		paneldescription.add(textdescription);
		panelid.add(labelidcarte);
		panelid.add(Box.createHorizontalStrut(50));
		panelid.add(textidcarte);
		panelbutton.add(buttonajouter);
		panelbutton.add(Box.createHorizontalStrut(20));
		panelbutton.add(buttoneffacer);
		panelbutton.add(Box.createHorizontalStrut(20));
		panelbutton.add(buttonannuler);
		mainpanel.add(paneltitre);
		mainpanel.add(paneldescription);
		mainpanel.add(panelid);
		mainpanel.add(panelbutton);
	}
    public void event()
    {   buttonannuler.addMouseListener(new MouseListener(){

		@Override
		public void mouseClicked(MouseEvent arg0) {
			// TODO Auto-generated method stub
			close();
		}

		@Override
		public void mouseEntered(MouseEvent arg0) {
			// TODO Auto-generated method stub
			
		}

		@Override
		public void mouseExited(MouseEvent arg0) {
			// TODO Auto-generated method stub
			
		}

		@Override
		public void mousePressed(MouseEvent arg0) {
			// TODO Auto-generated method stub
			
		}

		@Override
		public void mouseReleased(MouseEvent arg0) {
			// TODO Auto-generated method stub
			
		}
    	
    });
    	buttoneffacer.addMouseListener(new MouseListener(){

			@Override
			public void mouseClicked(MouseEvent arg0) {
				// TODO Auto-generated method stub
				texttitre.setText(null);
				textdescription.setText(null);
				textidcarte.setText(null);
			}

			@Override
			public void mouseEntered(MouseEvent arg0) {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void mouseExited(MouseEvent arg0) {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void mousePressed(MouseEvent arg0) {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void mouseReleased(MouseEvent arg0) {
				// TODO Auto-generated method stub
				
			}
    		
    	});
    }
    public void close()
    {
    	this.dispose();
    }
}
